﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.Infrastructure;
using DLM.Domain.Model;

namespace DLM.Data.EF.CodeFirst.Mapping
{
    public class SupplierMap : EntityTypeConfiguration<Supplier>
    {
        public SupplierMap()
        {
            this.HasKey(t => t.SID);
            this.ToTable("Supplier");
            this.Property(t => t.SID).HasColumnName("SID");
            this.Property(t => t.MID).HasColumnName("MID");
            this.Property(t => t.Name).HasColumnName("Name").IsRequired().HasMaxLength(30);
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.Phone).HasColumnName("Phone").IsUnicode(false).HasMaxLength(20);
            this.Property(t => t.Order).HasColumnName("Order");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.HasRequired(t => t.Modality).WithMany(t => t.Supplier).HasForeignKey(d => d.MID);
        }
    }
}
